package written.test;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

/**
 * @Author: Dang Qi
 * @Date: 2021/4/6  19:51
 * @Description:
 */
public class Moun {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[sc.nextInt()];
        int[][] link = new int[sc.nextInt()][2];
        for(int i =0 ; i < a.length; i++)
            a[i] = sc.nextInt();
        for(int i =0 ; i < link.length; i++){
            link[i][0] = sc.nextInt()-1;
            link[i][1] = sc.nextInt()-1;
        }
        solve(a, link);
    }
    static int[] parent = null,deep = null,nums = null;
    public static void solve(int[] a, int[][] link){
        int n = a.length;
        parent = new int[n]; deep = new int[n]; nums = new int[n];
        for(int i = 0; i < a.length; i++){
            parent[i] = i;
            deep[i] = a[i];
            nums[i] = 1;
        }
        for(int i = 0; i < link.length; i++)
            union(link[i][0], link[i][1]);
        for(int i = 0; i < n; i++){
            int root = findRoot(i);
            System.out.println(deep[root]*1.0/nums[root]);
        }
    }
    public static int findRoot(int x){
        while (x != parent[x])
            x = parent[x];
        return  x;
    }
    public static void union(int x, int y){
        int x_root = findRoot(x);
        int y_root = findRoot(y);
        if(x_root==y_root) return;
        parent[x_root] = y_root;
        deep[y_root] += deep[x_root];
        nums[y_root] += nums[x_root];
    }
}
